package ca.etsmtl.log720.tp3.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import ca.etsmtl.log720.tp3.dao.Dossier;
import ca.etsmtl.log720.tp3.service.DossierService;

@Controller
public class DossierController {

    @Autowired
    private DossierService dossierService;

    @RequestMapping(value = {"/dossier/show", "/dossier"})
    public String listContacts(Map<String, Object> map) {
        
        System.out.println("ghjghghghhghgghghgghghghghghhghgh");
        map.put("dossier", new Dossier());
        map.put("dossierList", dossierService.listDossier());

        return "dossier";
    }

    @RequestMapping(value = "/dossier/add", method = RequestMethod.POST)
    public String addContact(@ModelAttribute("contact") Dossier dossier, BindingResult result) throws Exception {

        dossierService.addDossier(dossier);

        return "redirect:/dossier";
    }
    /*
     @RequestMapping("/addInfractionDossier")
     public String deleteContact(@PathVariable("contactId")
     Integer contactId) {
 
     contactService.removeContact(contactId);
 
     return "redirect:/dossier";
     }*/
}
